//
//  LGChooseAllTableViewCell.m
//  LuxuryGoods
//
//  Created by 纳里健康 on 2018/5/25.
//  Copyright © 2018年 Future. All rights reserved.
//

#import "LGChooseAllTableViewCell.h"

@implementation LGChooseAllTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.goToPayBtn.layer.cornerRadius = self.goToPayBtn.height/2;
    self.goToPayBtn.layer.masksToBounds = YES;
    
}


- (void)setPrice:(CGFloat)price AndStrleWithDeleteType:(BOOL)canDelete deleteArray:(NSMutableArray *)array
{
    _isDelete = canDelete;
    
    NSString *choose = self.chooseAll == NO ? @"tab_normal" : @"tab_selected";
    
    self.allChooseImage.image = [UIImage imageNamed:choose];
    
    if(canDelete == YES)
    {
        self.totalLabel.hidden = YES;
        self.allPriceLabel.hidden = YES;
        [self.goToPayBtn setTitle:@"删除" forState:UIControlStateNormal];
        [self.goToPayBtn setTitleColor:WHITE_COLOR forState:UIControlStateNormal];
        if(array.count == 0)
        {
            self.goToPayBtn.backgroundColor = UIColorFromRGB(0xD9D9D9);
            self.goToPayBtn.userInteractionEnabled = NO;
        }else
        {
            self.goToPayBtn.backgroundColor = UIColorFromRGB(0xE3D3AF);
            self.goToPayBtn.userInteractionEnabled = YES;
        }
    }else
    {
        NSString *peiceStr = price == 0 ? @"0" : [NSString stringWithFormat: @"￥ % .2f",price];
        
        self.allPriceLabel.text = peiceStr;
        self.totalLabel.hidden = NO;
        self.allPriceLabel.hidden = NO;
        [self.goToPayBtn setTitle:@"结算" forState:UIControlStateNormal];
    }
    
}

//全选点击事件
- (IBAction)chooseAllAction:(id)sender {
    
    self.chooseAll = !self.chooseAll;
    
    //这里要有代理把全选操作传递出去
    if([self.delegate respondsToSelector:@selector(ChooseAllCommodityWithStatus:)])
    {
        [self.delegate ChooseAllCommodityWithStatus:self.chooseAll];
    }
}

//结算按钮点击事件
- (IBAction)PayAction:(id)sender {
    
    if(_isDelete)
    {
        NSLog(@"点击了删除");
    }else
    {
        NSLog(@"点击了结算");
    }
    
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
